import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testCase="DBshop005_订单管理查询流程"

firefox=openBrowser(url)
DBshopLogin(firefox,userName,password)

firefox.find_element_by_link_text("我的订单").click()
firefox.find_element_by_partial_link_text('交易完成').click()
ordernumber=firefox.find_elements_by_xpath('//table/thead/tr/th/div/a')[0].text
print('搜索订单号为：%s' % ordernumber)
firefox.quit()

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'销售管理','订单管理')
firefox.find_element_by_name('order_sn').send_keys(ordernumber)
firefox.find_element_by_xpath('(//button[@type="submit"])[1]').click()
time.sleep(1)

try:
    firefox.find_element_by_link_text('打印订单').is_displayed()
    writeLog("%s 测试通过"%testCase)
    print("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
    print("%s 测试失败" % testCase)
firefox.quit()